package com.cskaoyan.config;

import com.cskaoyan.interceptor.HandlerInterceptor1;
import com.cskaoyan.interceptor.HandlerInterceptor2;
import com.cskaoyan.interceptor.HandlerInterceptor3;
import com.cskaoyan.interceptor.HandlerInterceptor4;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author stone
 * @date 2022/09/01 15:52
 */
@ComponentScan("com.cskaoyan.controller")
@EnableWebMvc
public class MvcConfiguration implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //HandlerInterceptor是谁
        //作用范围是什么
        //多个HandlerInterceptor的顺序 → 书写顺序
        registry.addInterceptor(new HandlerInterceptor1()).addPathPatterns("/hello/**");
        registry.addInterceptor(new HandlerInterceptor2());//.addPathPatterns("/**");
        registry.addInterceptor(new HandlerInterceptor3()).addPathPatterns("/goodbye/**");
        registry.addInterceptor(new HandlerInterceptor4());//.addPathPatterns("/**");
    }
}
